package cn.wjzhang.utils;

import com.alibaba.druid.filter.config.ConfigTools;

/**
 * ========================
 * Druid数据库密码加密
 *
 * @author wjzhang
 * @version v1.0
 * ========================
 * @date 2023/6/12 15:39
 */
public class DruidEncryptUtils {
    public static void main(String[] args) {

        try {
            String[] strings = ConfigTools.genKeyPair(512);
            String sy = strings[0];
            String gy = strings[1];
            System.out.println("私钥："+sy);
            System.out.println("公钥："+gy);
            String password = "appview";
            String encryptPassword = ConfigTools.encrypt(sy, password);
            System.out.println("密码加密为："+ encryptPassword);
            System.out.println("密码解密为："+ ConfigTools.decrypt(gy,encryptPassword));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
